import { ref } from 'vue'
import store from '@/app/store'
import { main } from '@/api/provider/miravia'

// 初始化
const miraviaStore = store()

// 授权完成
miraviaStore.ok = ref(false)

// 加载
miraviaStore.main = () => {
  return new Promise((resolve, reject) => {
    main().then(res => {
      if(res) {
        miraviaStore.ok.value = true
        miraviaStore.setData(res)
        return resolve(res)
      }
      miraviaStore.ok.value = false
      reject(res)
    }).catch(err => {
      reject(err)
    })
  })
}

export default miraviaStore